import request from '@/network/request.js'

export function getMenu () {
  return new Promise((resolve, reject) => {
    let menuData = []
    request.get('/sysMenu/getMenuList').then(res => {
      if (res.data.flag) {
        menuData = res.data
        resolve(menuData)
      }
    })
  })
}

export function filterMenu (menuList) {
  const menuData = []
  menuList.forEach(element => {
    if (element.pid == 0) {
      element.children.forEach(item => {
        menuData.push(item)
      })
    }
  })
  return menuData
}
